home *** CD-ROM | disk | FTP | other *** search
- Path: pki-nbg.philips.de!usenet
- From: ln_hwe@hln56.pki-nbg.philips.de (Harald Wellmann)
- Newsgroups: comp.object,comp.lang.c++
- Subject: Re: A design question
- Date: 23 Feb 1996 09:10:38 +0100
- Organization: Lucent Technologies
- Sender: ln_hwe@hln56.pki-nbg.philips.de
- Message-ID: <pvcybpuqx6p.fsf@hln56.pki-nbg.philips.de>
- References: <1996Feb22.234825.18755@dcs.warwick.ac.uk>
- NNTP-Posting-Host: hln56.pki-nbg.philips.de
- In-reply-to: miro@dcs.warwick.ac.uk's message of Thu, 22 Feb 1996 23:48:25 GMT
- X-Newsreader: Gnus v5.1
-
- In article <1996Feb22.234825.18755@dcs.warwick.ac.uk> miro@dcs.warwick.ac.uk (Miroslav J Walker) writes:
-
- I'm trying to model input from a user being processed over a series of
- steps.
- Input is parsed, put into a queue and then interpreted on a timer. My
- question is how to model the idea of it being the same bit of data
- (essentially) taking on several forms as it proceeds along the 'pipeline' of
- processing.
-
-
- There's a book called "Design Patterns" by Erich Gamma, where the pattern
- you seem to be thinking of is called a "Chain of Responsibility".
-
- (The book is very useful, I think, but maybe not for beginners.)
-
- The idea of this pattern is to define a class `Event' encapsulating
- the data to be processed along the chain.
-
- Then there is an abstract base class `EventHandler' with methods
- `forward(Event&)' and `process(Event&)' and an attribute
- `EventHandler* next_handler'.
-
- You can derive several types of event handlers from this class,
- processing the event in a different way.
-
- Then you construct instances of these handlers and link them to form a chain.
-
- Each handler will process the event in its own style and then forward
- it to the next handler.
-
- For more details, read the book!
-